<?php

/***** 其它包含中文字符的 functions *****/

// 计算post的显示时间
function get_past_time($datetime) {

	$leaves_starttime_hours = mysql2date('G', $datetime);
	$leaves_starttime_mins = mysql2date('i', $datetime);
	$leaves_starttime_month = mysql2date('n', $datetime);
	$leaves_starttime_day = mysql2date('d', $datetime);
	$leaves_starttime_year = mysql2date('Y', $datetime);
	
	$start_time_value=mktime($leaves_starttime_hours,$leaves_starttime_mins,1,
                            $leaves_starttime_month,$leaves_starttime_day,$leaves_starttime_year);
	$end_time_value=time();

	$total_secs=(int)$end_time_value-(int)$start_time_value;
	$total_mins=(int)$total_secs/60;
	$total_hours=(int)$total_mins/60;

	$total_days=(int)($total_hours/24);
	$hours=$total_hours%24;
	$mins=$total_mins%60;

	//$the_past_time = $total_days."天 ".$hours."小时 ".$mins."分";
	$the_past_time = "";
	if($total_days != 0){
		$the_past_time .= $total_days."天 ";
		$the_past_time .= $hours."小时 ";
	}
	elseif($hours != 0)
		$the_past_time .= $hours."小时 ";
	$the_past_time .= $mins."分";

	return $the_past_time;
}

function the_past_time($echo = true) {
    global $post;

	$the_past_time = get_past_time($post->post_date);

	if ($echo)
    	echo $the_past_time;
	else
		return $the_past_time;
}

function get_favorit_link(){
	global $trdb, $user_ID;
	
	if(get_currentuserinfo()){
		$cuurent_postID = the_post_id(false);
		$request = "SELECT count(rel_id) FROM $trdb->post2user WHERE post_id=$cuurent_postID and user_id=$user_ID";
		$count = $trdb->get_var($request);
		if($count == 0)
			$favorit_link = "<A href=\"javascript:wrapper_full(".the_post_id(false).")\">收藏</A>";
		else
			$favorit_link = "<span>已收藏</span>";
	}
	else{
		$favorit_link = "<A href=\"javascript:wrapper_full(".the_post_id(false).")\">收藏</A>";
	}
	echo $favorit_link;
}

function get_post_nav(){
	global $trdb,$db_query;
	$url_param = "";
	
	if(isset($db_query->query_vars['p']))
		$page_num = $trdb->escape($db_query->query_vars['p']);
	else
		$page_num = 1;
		
	$text = "";

	$place_join_request = "";
	if(isset($db_query->query_vars['place'])){
			$place_tag = $trdb->escape($db_query->query_vars['place']);
			if(is_place_exist($place_tag)) {
				$place_join_request =" INNER JOIN $trdb->post2tag d ON a.ID=d.post_id";
				$place_join_request .=" INNER JOIN $trdb->tags e ON e.tag_ID=d.tag_id AND e.tag_name='$place_tag'";
			}
			else
				$place_join_request =" INNER JOIN $trdb->post2tag d ON 1=2";
		}
	
	if(is_home()){
		$pagepost_num = get_option('queue_post_count');
		$request = "SELECT count(a.ID) FROM $trdb->posts a";
		$request .= $place_join_request;
		$request .= " WHERE a.post_status = 'publish'";
		
		if($place_join_request==''){
			$request .= " AND a.post_favor = 'yes'";
		}
	}
	if(is_queue()){
		$pagepost_num = get_option('queue_post_count');
		$url_param = "queue&";
		$request = "SELECT count(a.ID) FROM $trdb->posts a";
		$request .= $place_join_request;
		$request .= " WHERE a.post_status = 'publish'";
		$request .= " AND post_favor = 'no'";
	}
	if(is_top10()){
		$url_param = "bestpost&";
		$pagepost_num = get_option('page_post_count');
		$request = "SELECT count(a.ID) FROM $trdb->posts a";
		//$request .= $place_join_request;
		$request .= " WHERE a.post_status = 'publish'";
	}
	if(is_user_home()){
		$pagepost_num = get_option('userpage_post_count');
		$url_param = "user=".the_user_name(false)."&";
		$request = "SELECT count(a.ID) FROM $trdb->posts a";
		$request .= " INNER JOIN $trdb->post2user b ON a.ID=b.post_id";
		$request .= " INNER JOIN $trdb->users c ON b.user_id=c.ID AND c.ID=".the_user_id(false);
		$request .= $place_join_request;
	}
	if(is_user_submitted()){
		$pagepost_num = get_option('userpage_post_count');
		$url_param = "user=".the_user_name(false)."&submitted&";
		$request = "SELECT count(a.ID) FROM $trdb->posts a";
		$request .= $place_join_request;
		$request .= " WHERE a.post_status = 'publish'";
		$request .= " AND a.post_author = ".the_user_id(false);
	}
	if(is_user_commented()){
		$pagepost_num = get_option('userpage_post_count');
		$url_param = "user=".the_user_name(false)."&commented&";
		$request = "SELECT count(a.ID) FROM $trdb->posts a";
		$request .= " INNER JOIN $trdb->comments b ON a.ID=b.comment_post_id AND b.comment_type='trip'";
		$request .= " INNER JOIN $trdb->users c ON b.comment_user_id=c.ID AND c.ID=".the_user_id(false);
		$request .= $place_join_request;
		$request .= " GROUP BY a.ID";
	}
	if(is_userlist()){
		$pagepost_num = get_option('userlist_count');
		$url_param = "userlist&";
		$request = "SELECT count(a.ID) FROM $trdb->users a";
	}
	if(is_tagadmin()){
		$pagepost_num = get_option('page_post_count');
		$url_param = "tagadmin&";
		$request = "SELECT count(a.tag_ID) FROM $trdb->tags a";
	}
	if (is_search())
		{
			$pagepost_num = get_option('page_post_count');			
			$keyword = trim($db_query->query_vars['search']);
			$url_param = "search=$keyword&";

			$keyword = apply_filters($keyword);
			$keyword = $trdb->escape($keyword);
			$keywords = explode(" ", $keyword);
			$keyword_count = count($keywords);

			if($keyword!=''){
				if(is_place_exist($keyword)) {
					$request = "SELECT COUNT(a.ID) from $trdb->posts a";
					$request .= " INNER JOIN $trdb->post2tag b ON a.ID=b.post_id";
					$request .= " INNER JOIN $trdb->tags c ON c.tag_id=b.tag_id AND c.tag_name = '$keyword'";
				}
				else{
					$request = "SELECT COUNT(a.ID) from $trdb->posts a WHERE (";
					
					for($i=0;$i < $keyword_count;$i++)
					{
						$kw = $keywords[$i];
						if($i!=0)
							$request .= " OR ";
						$request .= "a.post_title LIKE '%$kw%' OR a.post_content LIKE '%$kw%'";
					}
					$request .= ") AND a.post_status='publish'";
					/*
					if(isset($db_query->query_vars['area'])){
						if($db_query->query_vars['area'] == 'promoted')
							$request .= " AND a.post_favor='yes'";
						elseif($db_query->query_vars['area'] == 'queue')
							$request .= " AND a.post_favor='no'";
					}*/
				}
			}
			else $request = "SELECT COUNT(*) FROM $trdb->posts WHERE 1=2";
		}
	
	$total_num = $trdb->get_var($request);
	if(is_home()||is_queue())
		$total_num = $total_num + get_option('queue_post_count') - get_option('page_post_count');

	// if have place tag, add place param in the nav link
	if(isset($place_tag))
		$url_param .= "place=$place_tag&";

	if($total_num == 0)
		echo "";
	else{
		$total_page = $total_num/$pagepost_num;
		$mo = $total_num%$pagepost_num;
		if($mo != 0)
			$total_page = (int)$total_page+1;
		
		$current_page = $page_num;
		$pre_page_num = $current_page-1;
		$nxt_page_num = $current_page+1;
		
		// if not first page, add previous link
		if($current_page!=1)
			$text.= "<a href='?".$url_param."p=$pre_page_num' class=\"nextprev\" title=\"翻到上一页\">&#171; 上一页</a>";
		else
			$text.= "<span class=\"nextprev\">&#171; 上一页</span>";

		if($current_page==6&&$total_page>10)
			$text.= "<a href='?".$url_param."'  title=\"翻到第 1 页\">1</a>";
			
		// if total page > 10 and current page >= 7 add '...'
		if($total_page > 10&&$current_page>6){
			$text.= "<a href='?".$url_param."'  title=\"翻到第 1 页\">1</a>";
			$text.= "<a href='?".$url_param."p=2'  title=\"翻到第 2 页\">2</a>";
			$text.= "<span>...</span>";
		}
				
		for($i=1;$i<=$total_page;$i++){
			// if not current page, add number and link
			if(($i!=$current_page)&&
				((($i>=$current_page-4)&&($i<=$current_page+4)) || 
				($current_page<6&&$i<11) || 
				($current_page>($total_page-5)&&$i>($total_page-10)))
				)
			{
				if($i==1)
					$text.= "<a href='?".$url_param."'  title=\"翻到第 $i 页\">$i</a>";
				else
					$text.= "<a href='?".$url_param."p=$i'  title=\"翻到第 $i 页\">$i</a>";
			}
			// if is current page, only add number
			elseif($i==$current_page)
				$text.= "<span class=\"current\">$i</span>";
		}
		
		// if total page - current page > 7 add '...'
		if(($total_page - $current_page > 5)&&$total_page>10){
			$before_total_page = $total_page -1;
			$text.= "<span>...</span>";
			$text.= "<a href='?".$url_param."p=$before_total_page'  title=\"翻到第 $before_total_page 页\">$before_total_page</a>";
			$text.= "<a href='?".$url_param."p=$total_page'  title=\"翻到第 $total_page 页\">$total_page</a>";
		}
		
		if(($total_page - $current_page == 5)&&$total_page>10)
			$text.= "<a href='?".$url_param."p=$total_page'  title=\"翻到第 $total_page 页\">$total_page</a>";

		// if not last page, add next link
		if($current_page!=($total_page))
			$text.= " <a href='?".$url_param."p=$nxt_page_num' class=\"nextprev\" title=\"翻到下一页\">下一页 &#187;</a>";
		else
			$text.= "<span class=\"nextprev\">下一页 &#187;</span>";
		
		echo $text;
	}
}

function edit_post_link($link = '编辑', $before = '', $after = '') {
    global $post;

	if (!user_can_edit_post()) {
        return;
    }

    $location = get_settings('siteurl') . "?editpost&q=$post->ID&redirect_to=".urlencode($_SERVER['REQUEST_URI']);
    echo "$before <a href=\"$location\">$link</a> $after";
}

function hide_post_link($link = '隐藏', $before = '', $after = '') {
    global $post;

	if (!user_can_hide_post()) {
        return;
    }

    $location = "javascript:confirmHide($post->ID);";
    echo "$before <SPAN class=cursor_pointer style=\"color:#999999\" onclick=\"$location\">$link</SPAN> $after";
}

function hide_plan_link($link = '隐藏', $before = '', $after = '') {
    global $post;

	if (!user_can_hide_post()) {
        return;
    }

    $location = "javascript:confirmHidePlan($post->ID);";
    echo "$before <SPAN class=cursor_pointer style=\"color:#999999\" onclick=\"$location\">$link</SPAN> $after";
}

function draft_plan_link($link = '草稿', $before = '', $after = '') {
    global $post;

	if (!user_can_hide_post()) {
        return;
    }

    $location = "javascript:confirmDraftPlan($post->ID);";
    echo "$before <SPAN class=cursor_pointer style=\"color:#999999\" onclick=\"$location\">$link</SPAN> $after";
}

function promote_post_link() {
    global $post;

	if (!user_can_hide_post()) {
        return;
    }

    $location = "javascript:confirmPromote($post->ID);";
    echo "<span class=cursor_pointer onclick=\"$location\"><img src=\"".bloginfo('stylesheet_directory',false)."/img/c-digg.png\" width=\"14\" height=\"14\" alt=\"推选该文章\" /></span>";
}

function unfavorit_link() {
    global $post;

	if (!user_can_unfavor_post()) {
        return;
    }

    $location = "javascript:xajax_unfavoritFunc($post->ID);";
    echo "<SPAN class=tool><SPAN class=cursor_pointer style=\"color:#999999\" onclick=\"$location\">取消收藏</SPAN></SPAN>";
}

function get_comment_text(){
	
	
	$cuurent_postID = the_post_id(false);
	$type='trip';

	$comment_number = get_comment_number($cuurent_postID,$type);
	
	if($comment_number == 0){
		$linktext = "添加评论";
	}
	else
		$linktext = $comment_number." 条评论";

	echo $linktext;	
}

/* user profile functions */
function get_user_blog(){
	
	$blog_url = the_user_blog(false);
	if($blog_url=="")
		$blog_link = "<dd class=\"na\">[未输入]</dd>";
	else
		$blog_link = "<DD><A href=\"$blog_url\" target=\"_blank\">$blog_url</A></DD>";
	echo $blog_link;	
}

function edit_userprofile_link($link = '编辑', $before = '', $after = '') {

	if (!user_can_edit_profile()) {
        return;
    }

    echo "$before<SPAN onclick=\"javascript:xajax_editProfile();\"><a href=\"#\">$link</a></span>$after";
}

function get_place_list() {
	global $trdb,$db_query;
	
	$user_name = the_user_name(false);
	
	$place_tag = "";
	if(isset($db_query->query_vars['place'])){
		$place_tag = $db_query->query_vars['place'];
	}

	$add_param = "";

	if(is_user_home()){
		if($place_tag == "")
			echo "<li class=\"current\"><span><strong>全部&nbsp;(".the_user_favorited_number(false).")</strong></span></li>";
		else
			echo "<li><a href=\"./?user=$user_name\">全部&nbsp;(".the_user_favorited_number(false).")</a></li>";
		$request = "SELECT a.tag_name,COUNT(a.tag_name) AS tag_number FROM $trdb->tags a";
		$request .= " INNER JOIN $trdb->post2tag b ON a.tag_ID = b.tag_id";
		$request .= " INNER JOIN $trdb->post2user c ON c.post_id = b.post_id AND c.user_id=".the_user_id(false);
		$request .= " GROUP BY a.tag_name";
		$request .= " ORDER BY tag_number DESC";
		$request .= " LIMIT 15";

		$request2 = "SELECT COUNT(a.tag_name) AS total_tag FROM $trdb->tags a";
		$request2 .= " INNER JOIN $trdb->post2tag b ON a.tag_ID = b.tag_id";
		$request2 .= " INNER JOIN $trdb->post2user c ON c.post_id = b.post_id AND c.user_id=".the_user_id(false);
	}

	if(is_user_submitted()){
		$add_param = "&submitted";
		if($place_tag == "")
			echo "<li class=\"current\"><span><strong>全部&nbsp;(".the_user_submitted_number(false).")</strong></span></li>";
		else
			echo "<li><a href=\"./?user=$user_name&submitted\">全部&nbsp;(".the_user_submitted_number(false).")</a></li>";
		$request = "SELECT a.tag_name,COUNT(a.tag_name) AS tag_number FROM $trdb->tags a";
		$request .= " INNER JOIN $trdb->post2tag b ON a.tag_ID = b.tag_id";
		$request .= " INNER JOIN $trdb->posts c ON c.ID = b.post_id AND c.post_author=".the_user_id(false);
		$request .= " WHERE c.post_status='publish'";
		$request .= " GROUP BY a.tag_name";
		$request .= " ORDER BY tag_number DESC";
		$request .= " LIMIT 15";
		
		$request2 = "SELECT COUNT(a.tag_name) AS total_tag FROM $trdb->tags a";
		$request2 .= " INNER JOIN $trdb->post2tag b ON a.tag_ID = b.tag_id";
		$request2 .= " INNER JOIN $trdb->posts c ON c.ID = b.post_id AND c.post_author=".the_user_id(false);
		$request2 .= " WHERE c.post_status='publish'";
	}

	if(is_user_commented()){
		$add_param = "&commented";
		if($place_tag == "")
			echo "<li class=\"current\"><span><strong>全部&nbsp;(".the_user_commented_number(false).")</strong></span></li>";
		else
			echo "<li><a href=\"./?user=$user_name&commented\">全部&nbsp;(".the_user_commented_number(false).")</a></li>";
		$request = "SELECT a.tag_name,COUNT(a.tag_name) AS tag_number FROM $trdb->tags a";
		$request .= " INNER JOIN $trdb->post2tag b ON a.tag_ID = b.tag_id";
		$request .= " INNER JOIN $trdb->comments c ON c.comment_post_id = b.post_id AND c.comment_type='trip' AND c.comment_user_id=".the_user_id(false);
		$request .= " GROUP BY a.tag_name";
		$request .= " ORDER BY tag_number DESC";
		$request .= " LIMIT 15";
		
		$request2 = "SELECT COUNT(a.tag_name) AS total_tag FROM $trdb->tags a";
		$request2 .= " INNER JOIN $trdb->post2tag b ON a.tag_ID = b.tag_id";
		$request2 .= " INNER JOIN $trdb->comments c ON c.comment_post_id = b.post_id AND c.comment_type='trip' AND c.comment_user_id=".the_user_id(false);
	}

	$tag_lists = $trdb->get_results($request);
	$total_tag = $trdb->get_var($request2);
	
	for($i=0;$i<count($tag_lists);$i++) {
		$tag_list = $tag_lists[$i];
		$tag_list_name = $tag_list->tag_name;
		$tag_list_number = $tag_list->tag_number;
		
		if($tag_list_name == $place_tag)
			echo "<li class=\"current\"><span><strong>$tag_list_name&nbsp;($tag_list_number)</strong></span></li>";
		else
			echo "<li><a href=\"./?user=$user_name&place=$tag_list_name$add_param\">$tag_list_name&nbsp;($tag_list_number)</a></li>";
	}
	if($total_tag>15)
		echo "<li><a href=\"./?tagcloud&user=".the_user_name(false).$add_param."\">更多地区...</a></li>";
}

function get_nav_bar() {
	global $db_query;

	if(is_home()) {
		if(isset($db_query->query_vars['place'])) {
			if(is_place_exist($db_query->query_vars['place']))
				echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 标签: ".$db_query->query_vars['place']."</H2>";
			else
				echo "<h2><A href=".get_option('siteurl').">回到首页</A></h2>";
		}
		elseif(isset($db_query->query_vars['p'])) {
			if($db_query->query_vars['p'] ==1)
				echo "<h2><A href=".get_option('siteurl').">首页</A></h2>";
			else
				echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 第".$db_query->query_vars['p']."页</H2>";
		}
		else
			echo "<h2>最新推荐文章</h2>";
	}
	elseif(is_queue()) {
		if(isset($db_query->query_vars['p'])) {
			if($db_query->query_vars['p'] ==1)
				echo "<h2><A href=".get_option('siteurl').">首页</A> &#187; <A href=".get_option('siteurl')."/?queue>待选文章</A></h2>";
			else
				echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; <A href=".get_option('siteurl')."/?queue>待选文章</A> &#187; 第".$db_query->query_vars['p']."页</H2>";
		}
		else
			echo "<h2><A href=".get_option('siteurl').">首页</A> &#187; 待选文章</h2>";
	}
	elseif(is_page()) {
		echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; .".the_post_title()."</H2>";
	}
	elseif(is_about()) {
		echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 关于</H2>";
	}
	elseif(is_contact()) {
		echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 联系方式</H2>";
	}
	elseif(is_services()) {
		echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 服务条款</H2>";
	}
	elseif(is_tagcloud()) {
		if(isset($db_query->query_vars['user']))
			echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; ".$db_query->query_vars['user']."的标签云图</H2>";
		else
			echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 标签云图</H2>";
	}
	elseif(is_top10()) {
		echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 最热文章列表</H2>";
	}
	elseif(is_userlist()) {
		echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 用户列表</H2>";
	}
	elseif(is_search()) {
		if(isset($db_query->query_vars['search'])) {
			$search_key = apply_filters($db_query->query_vars['search']);
			echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 搜索: $search_key</H2>";
		}
		else
			echo "<H2><A href=".get_option('siteurl').">首页</A> &#187; 搜索</H2>";
	}
}

function the_title($echo=true) {
    global $trdb,$db_query;

	$tr_title = "";
	$tr_title_head = get_option('sitetitle');
    if(is_page()) {
		$post_id = $trdb->escape($db_query->query_vars['q']);
		$request = "SELECT post_title FROM $trdb->posts WHERE ID=$post_id";
		
		$post_title = $trdb->get_var($request);
		$tr_title = $tr_title_head." / ".$post_title;
    }
    elseif(is_queue()) {
		
		if(isset($db_query->query_vars['place'])) {
			if(is_place_exist($db_query->query_vars['place']))
				$tr_title = $tr_title_head." / ".$db_query->query_vars['place']."文章";
			else
				$tr_title = $tr_title_head;
		}
		else
			$tr_title = $tr_title_head;
	}
	elseif(is_home()) {
		$tr_title = $tr_title_head;
	}
    elseif(is_about()) {	
		
		$tr_title = $tr_title_head." / 关于";
    }
	elseif(is_contact()) {
		
		$tr_title = $tr_title_head." / 联系方式";
	}
	elseif(is_services()) {
		
		$tr_title = $tr_title_head." / 服务条款";
	}
	elseif(is_login()) {
		
		$tr_title = $tr_title_head." / 登录";
	}
	elseif(is_register()) {
		
		$tr_title = $tr_title_head." / 注册";
	}
	elseif(is_submit()) {
		
		$tr_title = $tr_title_head." / 提交新文章";
	}
	elseif(is_editpost()) {
		
		$tr_title = $tr_title_head." / 编辑文章";
	}
	elseif(is_user_home()) {
		
		$tr_title = $tr_title_head." / ".the_user_name(false)." / 收藏";
	}
	elseif(is_user_profile()) {
		
		$tr_title = $tr_title_head." / ".the_user_name(false);
	}
	elseif(is_user_submitted()) {
		
		$tr_title = $tr_title_head." / ".the_user_name(false)." / 提交";
	}
	elseif(is_user_commented()) {
		
		$tr_title = $tr_title_head." / ".the_user_name(false)." / 评论";
	}
    elseif(is_search()) {	
		
		if(isset($db_query->query_vars['search'])) {
			$search_key = apply_filters($db_query->query_vars['search']);
			$tr_title = $tr_title_head." / 搜索 / ".$search_key;
		}
		else
			$tr_title = $tr_title_head." / 搜索";
    }
    else {
    	$tr_title = $tr_title_head;
    }
    
	if ($echo)
    	echo $tr_title;
	else
		return $tr_title;

}

function get_popup_urls() {
	global $trdb;
	$cuurent_postID = the_post_id(false);
	
	$request = "SELECT post_url FROM $trdb->postaddurl WHERE post_id=$cuurent_postID ORDER by rel_id";
	$urls = $trdb->get_results($request);
	$result = "";

	if(count($urls)==0){
		$url1 = the_post_url(false);
		$result = "<DIV class=news-readall>";
		$result .= "<P><img align=\"abs_middle\" border=\"0\" src=\"".bloginfo('stylesheet_directory',false)."/img/friend-tab.gif\" width=\"13\" height=\"11\" />&nbsp;<A href=\"$url1\" target=_blank>阅读全文</A></P>";
		$result .= "</DIV>";
	}
	else{
		$url1 = the_post_url(false);
		$result = "<DIV class=news-readall>";
		$result .= "<P><img align=\"middle\" border=\"0\" src=\"".bloginfo('stylesheet_directory',false)."/img/friend-tab.gif\" width=\"13\" height=\"11\" />&nbsp;<A href=\"javascript://\" onclick=\"new Effect.SlideDown('popup_url_$cuurent_postID'); return false;\">阅读全文</A></P>";
		$result .= "<div id=\"popup_url_$cuurent_postID\" style=\"display:none\" class=news-readall2><span>";

		$url_display = substr_for_gb2312($url1,0,70);
		$result .= "1. <A href=\"$url1\" target=_blank>$url_display</A><br/>";

		for($i=0;$i<count($urls);$i++)
		{
			$url = $urls[$i]->post_url;
			$url_display = substr_for_gb2312($url,0,70);
			$result .= ($i+2).". <A href=\"$url\" target=_blank>$url_display</A><br/>";
		}
		$result .= "<br/><A href=\"javascript://\" onclick=\"new Effect.SlideUp('popup_url_$cuurent_postID'); return false;\">关闭</A>";
		$result .= "</span></div></DIV>";
	}
	
	echo $result;
}

function delete_plan_link($link = '删除', $before = '', $after = '') {
    global $post;

	if (!user_can_edit_plan()) {
        return;
    }

    $location = "javascript:confirmDeletePlan($post->ID);";
    echo "$before <SPAN onclick=\"$location\"><A href=\"javascript://\">$link</A></SPAN> $after";
	
}

?>